<template>
	<view class="choose-main">
			<course-tree style="padding: 15px;" :initNode="node" @changeCourse="changeCourse"></course-tree>
			<scroll-view class="choose-course" scroll-y="true">
				<myCourse style="margin-bottom:10px" v-if="user"></myCourse>
				<hr/>
				<Schedule  :search="search"></Schedule>
			</scroll-view>
	</view>
</template>

<script>
	
	const db = uniCloud.database();
	const dbCmd = db.command;
	const dbCollectionName = 'teaching-class';
	
	import {mapState} from 'vuex'
	import courseTree from './courseTree.vue'
	import myCourse from '../../components/my-course/my-course.vue'
	export default {
		components:{
			courseTree,
			myCourse
		},
		data() {
			return {
				node:[],
				search:''
			}
		},
		computed:{
			user : ({ $store }) => $store.state.user.userInfo
		},
		
		async onLoad(){
			await this.initNode()
		},
		
		methods: {
			/**
			 * 课程目录
			 */ 
			initNode(){
				console.log(this.user)
				this.$request('choose/courseCatalogue',{id:this.user.username}).then((res)=>{this.node = res})
			},
			changeCourse(value){
				this.search = value
			},
		}
	}
</script>

<style scoped>
	.choose-main{
		display: flex;
		flex-direction: row;
	}
	.choose-course{
		
		/* height: calc(100vh - (var(--top-window-height))); */
		height: 880px;
	}
</style>
